home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / adynware / settings.pm < prev    next >
Encoding:
Perl POD Document  |  1999-12-28  |  1.3 KB  |  51 lines

  1. package Settings;
  2. use strict;
  3. #use diagnostics;
  4. use adynware::utility_file;
  5. use Data::Dumper;
  6.  
  7. sub save
  8. {
  9.         my $self = shift;
  10.         my($valuesReference, $namesReference) = @_;
  11.         $Data::Dumper::Purity = 1;
  12.         my $dumper = Data::Dumper->new($valuesReference, $namesReference);
  13.         my $newContent = $dumper->Dump();
  14.                         
  15.         my $file = $self->{"file"};
  16.         my $oldContent = utility_file::getContent("$file.ini");
  17.         utility_file::setContent("$file.old", $oldContent);
  18.         utility_file::setContent("$file.ini", $newContent);
  19. }
  20.  
  21. sub load
  22. {
  23.         my($self) = @_;
  24.         my $file = $self->{"file"};
  25.         my $error = 0;
  26.         my $content = utility_file::getContent("$file.ini");
  27.         if (!$content)
  28.         {
  29.                 print "Settings::load could not load $file.ini\n";
  30.                 $content = utility_file::getContent("$file.old");
  31.                 print "Settings::load could not load $file.old\n" unless $content;
  32.         }
  33.         if ($content)
  34.         {
  35.                 $content =~ s/\015//g;
  36.                 return $content;
  37.         }
  38.         return "";
  39. }
  40.  
  41. sub new
  42. {
  43.         my $class = shift;
  44.         my $self = {};
  45.         bless $self, $class;
  46.         $self->{"file"} = shift;
  47.         return $self;
  48. }
  49.  
  50. 1;
  51.